package rpc.proxy.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @ClassName: SmsInvocationHandler
 * @Description: 自定义调用过程
 * @author: Kowk
 * @since:1.0.0
 */
public class SmsInvocationHandler implements InvocationHandler {
    private final Object target;

    public SmsInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //调用实际方法之前添加任意操作
        System.out.println("调用之前执行相应操作");
        Object res = method.invoke(target, args);
        //调用实际方法之后添加任意擦欧洲哦
        System.out.println("调用之后执行相应操作");
        return res;
    }
}
